home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / games / texturemapping / dumpchunky.c < prev    next >
C/C++ Source or Header  |  1980-01-03  |  2KB  |  102 lines

  1. #include <exec/types.h>
  2. #include <clib/exec_protos.h>
  3. #include <graphics/view.h>
  4. #include <intuition/intuition.h>
  5. #include <intuition/screens.h>
  6. #include <stdio.h>
  7. #define NO_PRAGMAS 1
  8. #include "pd:ifflib/iff.h"
  9.  
  10. #pragma libcall IFFBase OpenIFF 1e 801
  11. #pragma libcall IFFBase CloseIFF 24 901
  12. #pragma libcall IFFBase FindChunk 2a 902
  13. #pragma libcall IFFBase GetBMHD 30 901
  14. #pragma libcall IFFBase GetColorTab 36 8902
  15. #pragma libcall IFFBase DecodePic 3c 8902
  16. #pragma libcall IFFBase SaveBitMap 42 a9804
  17. /*#pragma libcall IFFBase SaveClip 48 210a9808*/
  18. #pragma libcall IFFBase IFFError 4e 0
  19. #pragma libcall IFFBase GetViewModes 54 901
  20. #pragma libcall IFFBase NewOpenIFF 5a 802
  21. #pragma libcall IFFBase ModifyFrame 60 8902
  22.  
  23. struct Library *GfxBase,*IntuitionBase,*IFFBase;
  24. struct BitMap *mybitmap;
  25. ULONG *infile;
  26.  
  27. void Fail(char *msg)
  28. {
  29.     if (msg) printf("%s\n",msg);
  30.     if (mybitmap) FreeBitMap(mybitmap);
  31.     if (GfxBase) CloseLibrary(GfxBase);
  32.     if (infile) CloseIFF(infile);
  33.     if (IFFBase) CloseLibrary(IFFBase);
  34.     exit(0);
  35. }
  36.  
  37.  
  38. struct Library *openlib(char *name,ULONG version)
  39. {
  40.     struct Library *t1;
  41.     t1=OpenLibrary(name,version);
  42.     if (! t1)
  43.     {
  44.         printf("error- needs %s version %d\n",name,version);
  45.         Fail(0l);
  46.     }
  47.     else return(t1);
  48. }
  49.  
  50.  
  51.  
  52.  
  53. ULONG lcolortab[2+256*3];
  54.  
  55. struct RastPort myrp;
  56.  
  57. main(argc,argv)
  58. int argc;
  59. char **argv;
  60. {
  61.     GfxBase=openlib("graphics.library",39);
  62.     IFFBase=openlib("iff.library",0);
  63.     if (argc==2)
  64.     {
  65.         if (infile=OpenIFF(argv[1]))
  66.         {
  67.             ULONG scrwidth,scrheight,scrdepth;
  68.             ULONG i,j;
  69.             struct IFFL_BMHD *bmhd;
  70.             if(!(bmhd=GetBMHD(infile))) Fail("BitMapHeader not found");
  71.             InitRastPort(&myrp);
  72.  
  73.             scrwidth = bmhd->w;
  74.             scrheight = bmhd->h;
  75.             scrdepth = bmhd->nPlanes;
  76.             mybitmap=AllocBitMap(scrwidth,scrheight,scrdepth,BMF_CLEAR,0l);
  77.             if (! mybitmap) Fail("no bitmap");
  78.             if(!DecodePic(infile,mybitmap)) Fail("Can't decode picture");
  79.             myrp.BitMap=mybitmap;
  80.             for(i=0;i<scrwidth;i++)
  81.             {
  82.                 for(j=0;j<scrheight;j++)
  83.                 {
  84.                     outb(ReadPixel(&myrp,i,j));
  85.                 }
  86.             }
  87.  
  88.             Fail(0);
  89.         }
  90.     }
  91. }
  92.  
  93. int curout=0;
  94.  
  95. outb(c)
  96. {
  97.     if (! curout) printf("\n\tdc.b\t"); else printf(",");
  98.     printf("$%02x",c);
  99.     curout++;
  100.     if (curout==15) curout=0;
  101. }
  102.